package com.sergio.gestion.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sergio.gestion.cto.SocioCto;
import com.sergio.gestion.entities.SecuenciasDao;
import com.sergio.gestion.entities.Socio;
import com.sergio.gestion.entities.SocioDao;
import com.sergio.gestion.form.SocioForm;
import com.sergio.gestion.util.Converter;

@Service("socioService")
public class SocioService {
	@Autowired
	private SocioDao socioDao;
	@Autowired
	private SecuenciasDao secuenciasDao;
	@Autowired
	private Converter converter;
	public List<Socio> obtenerSociosAll(Integer firstResult,Integer pageSize) {
		return this.socioDao.getAll(firstResult,pageSize);
	}
	public void guardarSocio(SocioCto socioCto) {
		if(socioCto.getId()==null){
			socioCto.setId(this.secuenciasDao.getNextSecuenciaSocios());}
		Socio socio=this.converter.toEnt(socioCto);
		this.socioDao.saveProduct(socio);
		
	}
	public Integer countSociosAll() {
		return this.socioDao.countAll();
	}
}
